package Realm;

sub new 
{
    my ($class) = @_;
    my $self    = {};

    $self->{active}     = "0,1";
    $self->{realm_id}   = "";
    $self->{username}   = "";
    $self->{password}   = "";
    $self->{f_name}     = "";
    $self->{l_name}     = "";
    $self->{signup_date}= "";
    $self->{signup_ip}  = "";

    bless $self, 'Realm';
    return $self;
}

sub get_all_realms 
{
    my $self        = shift;
    my $kit_db      = new KIT_DB();

    my @all_realms  = ();

    my $stmt    = "SELECT id, username, password, f_name, l_name,
                          signup_date, signup_ip, active
                   FROM   realm
                   WHERE  active IN " . "(" . $self->{active} . ")";

    my @rows	= $kit_db->GetMultipleRows($stmt);

    foreach (@rows) 
    {
        my %realm = 
        (
            realm_id    =>  $_->[0],
            username    =>  $_->[1],
            password    =>  $_->[2],
            f_name      =>  $_->[3],
            l_name      =>  $_->[4],
            signup_date =>  $_->[5],
            signup_ip   =>  $_->[6],
            active      =>  $_->[7],
        );
        push @all_realms, \%realm;
    }
    return @all_realms;
}
1;